/**
 * 游戏物体对象的基类
 * 
 * 所有对象都要实现这个类
*/

#ifndef __IOBJECT_H__
#define __IOBJECT_H__

#include "m_shader.h"
#include "Shape.h"
#include "glm_use.h"
#include <set>

class IObject
{
public:
    bool droped;
    static std::set<IObject *> objects;

    //位置
    glm::vec3 pos;
    IObject();
    virtual ~IObject();

    //绘制对象
    virtual void draw(Shader shader) = 0;

    //更新对象
    virtual void update(float dt) = 0;

    //获得对象列表
    static std::set<IObject *> getObjects();
};

class BlockObject : public IObject
{
public:
    bool out_of_edge;
    //所有方块
    static std::set<BlockObject *> blocks;
    //包含的方块图形
    Block block;
    //构造函数
    BlockObject(Block block);
    virtual ~BlockObject();
    //获得所有方块
    static std::set<BlockObject *> getBlocks();
};

class BallObject : public IObject
{
public:
    //所有球
    static std::set<BallObject *> balls;
    //球的图形
    Ball ball;
    //构造函数
    BallObject(Ball ball);
    virtual ~BallObject();
    //获得所有球
    static std::set<BallObject *> getBalls();
};

std::set<BlockObject *> getCollidedBlocks(const BallObject &ball);

void drawObjects(Shader shader);
void updateObjects(float dt);
void deinitObjects();
#endif